home *** CD-ROM | disk | FTP | other *** search
- > > And a general question about coding:
- > >
- > > What is a good procedure for detecting a "tap" of a fire button and a
- > > "press" (button held down)? - Carl Chavez
- > >
-
- >
- > PROCEDURE TESTHOLDBUTTON[STICK]
- > Shared LAST_TIME,START_TIME
- >
- > If Fire(STICK)
- > If LAST_TIME
- > 'Button is still held from previous call
- > Pop Proc[-1]
- > Else
- > If START_TIME=0
- > 'Beginning of a new press
- > START_TIME=Timer
- > Pop Proc[0]
- > Else
- > 'Button pressed in a previous call, but
- > 'timeout for a tap has not expired yet
- > If Timer-STARTTIME<2000
- > 'Cant decide which it is yet
- > Pop Proc[0]
- > Else
- > 'Decided it is a press
- > LAST_TIME=True
- > Pop Proc[-1]
- > End If
- > End If
- > End If
- > Else
- > 'Button not pressed.
- > If LAST_TIME
- > 'Just released from a press.
- > LAST_TIME=False
- > START_TIME=0
- > Pop Proc[0]
- > Else
- > If START_TIME
- > 'Was a tap
- > START_TIME=0
- > Pop Proc[1]
- > Else
- > 'Button Never Pressed at all.
- > Pop Proc[0]
- > End If
- > End If
- > End If
- > End Proc
- >
- > This returns:
- >
- > 0 = Nothing as happend / the fire button is pressed, but not
- > enough time has passed to tell if it is a tap or press
- > 1 = A tap has occured
- > -1 = A press has occured.
- >
- > It also has that advantage that it doesn't wait in the procedure for
- > 2000 50ths of a second, but exits immediately.As long as you call it
- > regularly, there won't be a problem, but if you leave it too long
- > between calls it might think taps are presses.
- >
- > Note - I haven't tested this - I don't have an amiga handy.
- >
- > - PAUL HICKMAN
-
- I tried out this routine last night and with some small modifications it worked.
- The logic was spot on, just some syntax and spelling problems.
-
- I couldn't get the "pop proc[1]" type statement working nor could I find
- reference to using pop proc in this manner. Please enlighten me if this
- is possible. I simply used:
-
- ; button declared as global
- button=1
- pop proc
-
- I think I had problems with the START_TIME variable name as it clashed with a
- reserved word so I just used BEGIN_TIME.
-
- Where Paul used "If START_TIME" I used "If BEGIN_TIME<>0".
- Are these If's testing the same thing? (notwithstanding my change of variable name)
-
- I would also like to test for the joystick being held or pressed to the left or right
- or just tapped as well as the button being tested in this manner. Later I will probably
- want to do the same for up and down!
-
- Q1. Should I incorporate all of this in the one procedure which checks every feature of
- the joystick in one test of the joy(1) function or should I write seperate procedures.
-
- Q2. I am just playing around with writing a program to move a car (bob that is) around on
- the screen eventually with the ability to make 15 degree turns in an overhead perspective.
- The controls would be something like : press and hold fire button to accelerate
- press left to turn anticlockwise by 15 degrees and right to turn clockwise 15 deg.
-
- The car is moving around the screen but is a little (well, a lot) erratic and the feel
- is just not there.
-
- Has anybody out there written a car racing game that would give me some clues or code
- or logic for handling the "mechanics" of steering a car around.
-
- Q3. I seem to recall the Skidmarks game documentation referring to using BSpline quadratics
- for the movement of the cars around corners. Does anybody know anything about that?
- I seem to recall that they even supplied some of the assembler code they used. Yes I
- know it was written in Blitz Basic but they also used calls to assembler code.
-
- Thanks ,
- Max Monahan
- M.Monahan@bom.gov.au
-
-
-